package com.ds.bpm.web;

import com.ds.bpm.client.ProcessDefForm;
import com.ds.bpm.client.data.FormClassBean;
import com.ds.bpm.client.service.FDTService;
import com.ds.bpm.engine.BPMException;
import com.ds.bpm.engine.WorkflowClientService;
import com.ds.config.ErrorResultModel;
import com.ds.config.ResultModel;
import com.ds.esb.config.EsbBeanAnnotation;
import com.ds.jds.core.esb.EsbUtil;

import java.util.List;

@EsbBeanAnnotation(id = "FDTService", name = "FDTService", expressionArr = "FDTServiceImpl()", desc = "FDTService")
public class FDTServiceImpl implements FDTService {

    @Override
    public ResultModel<FormClassBean> getActivityMainFormDef(String activityDefId) {
        ResultModel<FormClassBean> result=new  ResultModel<FormClassBean>();

        return result;
    }

    @Override
    public ResultModel<List<FormClassBean>> getAllActivityDataFormDef(String activityDefId) {

        ResultModel<List<FormClassBean>> result=new  ResultModel<List<FormClassBean>>();

        return result;
    }

    @Override
    public ResultModel<ProcessDefForm> getProcessDefForm(String processDefVersionId) {

        ResultModel<ProcessDefForm> result=new  ResultModel<ProcessDefForm>();
        try {
            ProcessDefForm processDefForm =getClient().getMapDAODataEngine().getProcessDefForm(processDefVersionId, null);
            result.setData(processDefForm);
        } catch (BPMException e) {
            result = new ErrorResultModel();
            ((ErrorResultModel) result).setErrcode(e.getErrorCode());
            ((ErrorResultModel) result).setErrdes(e.getMessage());
        }
        return result;
    }


    /**
     *
     *
     * @return
     */
    public WorkflowClientService getClient() {

        WorkflowClientService client = ((WorkflowClientService) EsbUtil.parExpression("$BPMC"));

        return client;
    }

}
